/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projeto_piu;

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 *
 * @author LUANTAVARES
 */
//Parte 02
// Checkbox com 4 (quatro) opções
// Pelo menos 2 devem alterar algo na interface ou exibir mensagem de texto no prompt


public class Parte02 {
    
    private Container container;
    private JLabel cb01;
    private JLabel cb02;
    private List<JLabel> listaLabels;
    
    public Parte02(JFrame janela){
        container = janela.getContentPane();
        this.listaLabels = new ArrayList<JLabel>();
        cb01 = new JLabel("");
        cb02 = new JLabel("");
    }
    
    public void executar(){
        this.addCheckBoxs();
    }
    
    private void addCheckBoxs(){
        final JCheckBox jCheckBox01 = new JCheckBox("CheckBox 01");
        final JCheckBox jCheckBox02 = new JCheckBox("CheckBox 02");
        JCheckBox jCheckBox03 = new JCheckBox("CheckBox 03");
        JCheckBox jCheckBox04 = new JCheckBox("CheckBox 04");
        
        ///
        ActionListener actionListener = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if(jCheckBox01.isSelected()){
                   cb01.setText("CheckBox01 selecionado");
                } else {
                   cb01.setText(""); 
                }
                if(jCheckBox02.isSelected()){
                   cb02.setText("CheckBox02 selecionado");
                } else {
                   cb02.setText(""); 
                }
            }
        };
        jCheckBox01.addActionListener(actionListener);
        jCheckBox02.addActionListener(actionListener);

        
        ///
        
        JPanel pane1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        JPanel pane2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        
        
        container.setLayout(new GridLayout(5, 1));
        
        pane1.add(jCheckBox01);
        pane1.add(jCheckBox02);
        pane1.add(jCheckBox03);
        pane1.add(jCheckBox04);
        pane2.add(this.cb01);
        pane2.add(this.cb02);
        
        this.container.add(pane1);
        this.container.add(pane2);
    }
    
}
